package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.GlowedNodeCurrencyServiceAttrHandler;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.GlowedNodePriceServiceAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.scene.attr.OperateInstAttrService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @author zhoubang
 * 云聚节点-云联网专线接入产品-新版-节点费属性联动
 */
@Service
@AttrHandler(GlowedNodePriceServiceAttrHandler.class)
public class GlowedNodePriceServiceAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Autowired
    IQuerySceneInstService querySceneInstService;

    @Autowired
    OperateInstAttrService operateInstAttrService;

    @Override
    public void handle(KiteAttr kiteAttr, KiteInst inst, AttrData data) {

        KiteAttr attr = inst.getAttr("200002148");
        KiteAttr attrRate = inst.getAttr("200002149");
        String value = attr.getValue();
        if (StringUtils.isEmpty(value)) {
            value = attr.getValueDesc();
        }
        if (StringUtils.isNotEmpty(value) && StringUtils.isNotEmpty(kiteAttr.getValueDesc())) {
            attrRate.setValueDesc(String.valueOf(Double.parseDouble(kiteAttr.getValueDesc()) / Double.parseDouble(value)));
        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData data) {

    }

}
